/**
 * Created by Administrator on 2018/8/17.
 */
var $CertusJsonAjax;
var $CertusFromAjax;
var $$scope;
InitCertusJqNumLimit();
// 资产库可用资产信息
var purchaseProductDatas = new Array();
var purchaseStepEntity;
var bqArray = {};
var oldBqArray = {};
// 采购记录
var proc1Columns = [{
    id: 'commodityCateName',
    title: '类目',
    width: 73,
    type: 'string',
    columnClass: 'text-center',
}, {
    id: 'commodityClassName',
    title: '类别',
    width: 73,
    type: 'string',
    columnClass: 'text-center',
}, {
    id: 'name',
    title: '名称',
    width: 73,
    type: 'string',
    columnClass: 'text-center',
}, {
    id: 'descAndSpec',
    title: '品名及规格',
    width: 200,
    type: 'string',
    columnClass: 'text-left',
}, {
    id: 'quantity',
    title: '数量',
    width: 100,
    type: 'string',
    columnClass: 'text-center',
}, {
    id: 'estimatedAmount',
    title: '预计金额',
    width: 150,
    type: 'string',
    columnClass: 'text-center',
    resolution: function (value, record, column, grid, dataNo, columnNo) {
        var content = '￥' + value + '元';
        return content;
      }
}, {
    id: 'remark',
    title: '备注',
    type: 'string',
    columnClass: 'text-left',
}];


function showNowQuote(biCode) {
    if (biCode) {;
        belowGrid.exhibitDatas = bqArray[biCode];
        belowGrid.refresh(false);

        ;
        endGrid.exhibitDatas = oldBqArray[biCode]
        endGrid.refresh(false);


        $(".hdlog").show();
        $(".hdgbuy").show();
    }
}

function showAllQuote() {
    var tempArray = new Array();
    if (bqArray) {
        for (var j in bqArray) {
            tempArray = tempArray.concat(bqArray[j]);
        }
    }
    belowGrid.exhibitDatas = tempArray;
    belowGrid.refresh(false);

    $(".hdgbuy").show();
}

var prcListColumns = [
    {
        id: 'asset_style1',
        title: '资产类目',
        width: 73,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'asset_style2',
        title: '资产类别',
        width: 73,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'asset_id',
        title: '资产编号',
        width: 170,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'comments',
        title: '资产描述',
        type: 'string',
        columnClass: 'text-left',
    }, {
        id: 'asset_status',
        title: '状态',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            return "空闲";
        }
    }, {
        id: 'createUserId',
        title: '归属人',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'pro_name',
        title: '归属项目',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'city_location',
        title: '放置地',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
    }];


function shupload(bqCode, biCode) {
    $(".hdupload").show();
    $$scope.agreementAaaa = {};
    $$scope.agreementAaaa.bqCode = bqCode;
    $$scope.agreementAaaa.biCode = biCode;
}

function openAgreementDownloadList(bqCode, biCode) {

    if (biCode && bqCode) {
        var nowBq = bqArray[biCode];
        if (nowBq) {
            for (var i in nowBq) {
                if (nowBq[i].supplierFile && nowBq[i].bqCode == bqCode) {
                    $$scope.modalContent = eval(nowBq[i].agreementFile)
                }
            }
        }
    }
    // $$scope.modalContent = data.data;
    $$scope.ok = function () {
        $modalInstance.close(); // 点击确认后关闭弹窗
    };
    $$scope.cancel = function () {
        $modalInstance.dismiss('cancel'); // 点击取消后撤销模态框
    }
    var modalContent = $$scope.modalContent;

    $fileListService.openConfirmWindow("提示", modalContent).then(function (res) {});
}

//打开 下载 列表
function openDownloadList(bqCode, biCode) {

    if (biCode && bqCode) {
        var nowBq = bqArray[biCode];
        if (nowBq) {
            for (var i in nowBq) {
                if (nowBq[i].supplierFile && nowBq[i].bqCode == bqCode) {
                    $$scope.modalContent = eval(nowBq[i].supplierFile);
                }
            }

        }
    }
    // $$scope.modalContent = data.data;
    $$scope.ok = function () {
        $modalInstance.close(); // 点击确认后关闭弹窗
    };
    $$scope.cancel = function () {
        $modalInstance.dismiss('cancel'); // 点击取消后撤销模态框
    }
    var modalContent = $$scope.modalContent;

    $fileListService.openConfirmWindow("提示", modalContent).then(function (res) {});
}

function hdgs() {
    $(".hdgs").hide();
}

// 结果清单
var endColumns = [
    //     {
    //     id: 'number',
    //     title: '序号',
    //     width: 45,
    //     type: 'string',
    //     columnClass: 'text-center',
    // }, 
    {
        id: 'commodityCateName',
        title: '资产类目',
        width: 73,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'commodityClassName',
        title: '资产类别',
        width: 73,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'assetId',
        title: '资产编号',
        width: 170,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'descAndSpec',
        title: '资产描述',
        type: 'string',
        columnClass: 'text-left',
    }, {
        id: 'status',
        title: '状态',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
        resolution: function () {
            return "已经入库";
        }
    }, {
        id: 'belongto',
        title: '归属人',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'belongProj',
        title: '归属项目',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
    }
];
var belowGrid;
var aboveGrid;
var endGrid;
var brCode;


//文件列表下载
function downLoad(id) {
    var fileID = $(id).parent().parent().find(".fileDownloadPath").val();
    $CertusFormAjax.download("downloadFile", "fileId=" + fileID);
}
